<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$("#idCheck").bind("click", function(){ 
		$.ajax({
			url:"searchCompanyById.do",
			type:"GET",
			dataType:"JSON",
			data:"id="+$("#id").val(),//요청파라미터
			beforeSend:function(){//요청하기전 호출하는 함수 등록
				if($("#id").val()==""){
					$("#id").focus();
					return false;//false를 return 하면 요청을 하지 않는다. 
				}
			},
			
			success:function(jobj,msg,xhr){
				 
				
				/*
				for(var i=0;i<list.length;i++){
					list[i].id;
				}*/
			//	$("div").each(function(){}
			var txt = "";
				txt = jobj.idCheck;
				//alert(txt);
				//$.each(list,function(idx,obj){//반복할 배열을 넣고 호출할 함수를 넣어준다. 1. : 인덱스(0~), 2: 배열에서 가져온 값
				//	txt = txt+"id : "+obj.id+", 패스워드 : "+obj.password+", 이름 : "+obj.name+", 나이 : "+obj.age+"<br>";
					
				//});
				$("#idCheckLocation").html(txt);
			},
			error:function(xhr){
				alert("오류발생 : "+xhr.status);
			}
		});
	});
});
 
function registerCheck(){
	var id = document.registerForm.id;
	var pwd = document.registerForm.password;
	var passwordCheck = document.registerForm.passwordCheck;
	 
	var name = document.registerForm.name;
	var businessNo = document.registerForm.businessNo;
	 
	var email = document.registerForm.email;
	var phone1 = document.registerForm.phone1;
	var phone2 = document.registerForm.phone2;
	var phone3 = document.registerForm.phone3;
	
	if(id.value==""){
		alert("아이디를 입력해 주세요.");
		id.focus();
		return false;
	}
	if(pwd.value==""){
		alert("비밀번호를 입력해 주세요.");
		pwd.focus();
		return false;
	}
	if(pwd.value!=passwordCheck.value){
		alert("비밀번호와 비밀번호 확인이 같지 않습니다! 확인 후 다시 입력바랍니다.");
		passwordCheck.focus();
		return false;
	}
	if(businessNo.value==""){
		alert("사업자 번호를 입력하세요.");
		businessNo.focus();
		return false;
	}
 
	if(email.value==""){
		alert("email을 입력해 주세요.");
		email.focus();
		return false;
	}
	if(email.value==""){
		alert("email을 입력해 주세요.");
		email.focus();
		return false;
	}
	if(phone1.value=="" || phone2.value=="" || phone3.value==""){
		alert("전화번호를 입력해 주세요.");
		phone1.focus();
		return false;
	}
	if(name.value==""){
		alert("이름을 입력해 주세요.");
		name.focus();
		return false;
	}
	
}
function searchAddress(){
	window.open("/${initParam.context_root }/jsp/member/address_popup.jsp","search_address","scrollbars=yes, width=300, height=400, resizable=no");
	
}
</script>
</head>
<body>
<b>회원정보 입력</b>
<hr>
<input type="hidden" name="photo" size="20" maxlength="18">
<form action="/${initParam.context_root }/registerCompany.do" name="registerForm" onsubmit="return registerCheck()">
<b>* 필수정보</b>
<table border="1" cellpadding="5" cellspacing="0">
<tr>
<td bgcolor="lightgray"><b>아이디</b></td><td align="left"><input type="text" name="id" id="id" size="20" maxlength="18"><input type="button" id="idCheck" value="중복체크"><span id="idCheckLocation" style="color: red"></span></td>
</tr>
<tr>
<td bgcolor="lightgray"><b>비밀번호</b></td><td align="left"><input type="password" name="password" size="20" maxlength="20"><br>6자~20자 사이의 영문,숫자,특수문자를 혼용 하시면 더욱 안전합니다.</td>
</tr>
<tr>
<td bgcolor="lightgray"><b>비밀번호 확인</b></td><td align="left"><input type="password" name="passwordCheck" size="20" maxlength="18"></td>
</tr>
<tr>
<td bgcolor="lightgray"><b>사업번호</b></td><td align="left"><input type="text" name="businessNo" size="20"  maxlength="20"></td>
</tr>
<tr> 
<td bgcolor="lightgray"><b>이메일</b></td><td align="left"><input type="text" name="email" size="20" maxlength="20"></td>
</tr>
<tr>
<td bgcolor="lightgray"><b>전화번호</b></td><td align="left">
<select  name="phone1">
			<option id="010" selected="selected">010</option>
			<option id="011">011</option>
			<option id="016">016</option>
			<option id="017">017</option>
			<option id="019">019</option>
			</select>-<input type="text" name="phone2" size="4" maxlength="4">-<input type="text" name="phone3" size="4" maxlength="4">

</td>

</tr>

<tr>
<td colspan="2">
<b>- 추가정보</b>
</td>
</tr>
<tr>
<td bgcolor="lightgray"><b>이름</b></td><td align="left"><input type="text" name="name" size="20" maxlength="20"></td>
</tr>
<tr>
<td bgcolor="lightgray"><b>주소</b></td>
<td align="left"><input type="text" name="zipcode" size="7" maxlength="7"><input type="button" value="우편번호 검색" onclick="searchAddress()">
<br><input type="text" name="address" size="100" maxlength="100">
<input type="hidden" name="seq">
</td>
</tr>


<tr align="center" >
<td colspan="2" bgcolor="#afeeee"><input type="submit" value="전송"><input type="reset" value="초기화"></td>
</tr>

</table>
</form>
</body>
</html>